package io.framework.modules.water.controller;

import io.framework.common.utils.Result;
import io.framework.modules.water.service.OceanBuoyPointService;
import io.framework.modules.water.service.WaterMonitorService;
import io.framework.modules.water.service.WaterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.*;


/**
 * 水环境管理接口
 *
 * @author Gujq email
 * @since 1.0.0 2020-05-22
 */
@RestController
@Api(tags = "水环境管理接口")
public class WaterDataController {
    @Autowired
    private WaterService waterService;

    @Autowired
    private WaterMonitorService waterMonitorService;

    @Autowired
    private OceanBuoyPointService oceanBuoyPointService;

    @GetMapping("water/info/pass")
    @ApiOperation("水质达标情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1-地表水 2-城镇内河 3-重点治理城镇内河（湖） 4-饮用水源", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "date", value = "时间 2020-5", paramType = "query", dataType = "String", required = true)
    })
    public Result<Map<String, Object>> waterPass(@ApiIgnore @RequestParam Map<String, Object> params) {

        Map<String, Object> resultMap = waterService.getWaterPassInfo(params);

        return new Result<Map<String, Object>>().ok(resultMap);
    }

    @GetMapping("water/max/time")
    @ApiOperation("水质达标情况")
    public Result<Map<String, Object>> maxTime() {

        Map<String, Object> resultMap = waterService.maxTime();

        return new Result<Map<String, Object>>().ok(resultMap);
    }

    @GetMapping("water/info/rate")
    @ApiOperation("站点水质现状类别占比")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1-地表水 2-城镇内河 3-重点治理城镇内河（湖） 4-饮用水源", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "date", value = "时间 2020-5", paramType = "query", dataType = "String", required = true)
    })
    public Result<Map<String, Object>> waterRate(@ApiIgnore @RequestParam Map<String, Object> params) {

        Map<String, Object> map = waterService.getwaterRateInfo(params);

        return new Result<Map<String, Object>>().ok(map);
    }

    @GetMapping("water/info/ndMonthChange")
    @ApiOperation("站点污染物浓度月度变化")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateType", value = "1-年度 2-季度 3-月份", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "date", value = "年 2020、季 2020-Q1 2020-Q2 2020-Q3 2020-Q4、月 2020-04", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "stationName", value = "断面名称", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "factor", value = "因子 PH、YD-盐度、DOO2-溶解氧、COD-化学需氧量、H2PO4-活性磷酸盐、OIL-石油类、Nmin-无机氮、K2MnO4-高锰酸钾、NH3-氨氮、TP-总磷、TN-总氮", paramType = "query", dataType = "String", required = true),
    })
    public Result<List<Map<String, Object>>> ndMonthChange(@ApiIgnore @RequestParam Map<String, Object> params) {

        List<Map<String, Object>> mapList = waterMonitorService.getWaterndMonthChange(params);

        return new Result<List<Map<String, Object>>>().ok(mapList);
    }

    @GetMapping("water/info/getStationNameList")
    @ApiOperation("站点污染物浓度月度变化 -- 获取所有断面")
    public Result<List<Map<String, Object>>> getStationName() {

        List<Map<String, Object>> mapList = waterMonitorService.getStationName();

        return new Result<List<Map<String, Object>>>().ok(mapList);
    }

    @ApiOperation("获取海洋浮标点监测数据对比图")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startDate", value = "开始时间 2020-04-01", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "endDate", value = "结束时间 2020-04-30", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "stationCode", value = "站点编码 多个以英文“,”隔开", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "factor", value = "因子", paramType = "query", dataType = "String", required = true),
    })
    @GetMapping("water/ocean/getOceanInfoListByParams")
    public Result<List<Map<String, Object>>> getOceanInfoListByParams(@ApiIgnore @RequestParam Map<String, Object> params) {

        List<Map<String, Object>> list = oceanBuoyPointService.getOceanInfoListByParams(params);

        return new Result<List<Map<String, Object>>>().ok(list);
    }

    @ApiOperation("获取浮标点位 相同参数因子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationCode", value = "站点编码 多个以英文“,”逗号隔开", paramType = "query", dataType = "String", required = true)
    })
    @GetMapping("water/ocean/getOceanInfoLabel")
    public Result<List<Map<String, Object>>> getOceanInfoLabel(@ApiIgnore @RequestParam Map<String, Object> params) {

        List<Map<String, Object>> mapList = oceanBuoyPointService.getOceanInfoLabel(params);

        return new Result<List<Map<String, Object>>>().ok(mapList);
    }

}